<template>
  <div class="purchasing">
    <div class="shouye">
      <span>采购首页</span>
      <!--      <el-tag v-for="item in saleData" :key="item.name" @click="newlyOrder(item.path)">{{ item.name }}</el-tag>-->
    </div>
    <hr class="hr1">
    <ul class="header">
      <li @click="pushView(1)">
        <div class="firstHead">待审核调价表</div>
        <div class="lastHead">{{ headerInfo.patTotal }}</div>
      </li>
      <li @click="pushView('C')">
        <div class="firstHead">待审核请购单</div>
        <div class="lastHead">{{ headerInfo.requisiTotal }}</div>
      </li>
      <li @click="pushView1">
        <div class="firstHead">待审核采购单</div>
        <div class="lastHead">{{ headerInfo.pooTotal }}</div>
      </li>
      <li @click="pushView2">
        <div class="firstHead">未入库采购单</div>
        <div class="lastHead">{{ headerInfo.poowrTotal }}</div>
      </li>
      <li @click="pushView2">
        <div class="firstHead">迟交采购入库单</div>
        <div class="lastHead">{{ headerInfo.stockTotal }}</div>
      </li>
    </ul>
    <div class="context">
      <div class="rightListTop">
        <div>即将迟交明细表</div>
        <div>
          <el-button type="primary" size="mini" round @click="newlyOrder('/purchaseOrderList')">更多</el-button>
        </div>
      </div>
      <div>
        <jc-table
          :table-data="detailsData"
          :table-header="detailsHeader"
          table-height="400px"
        >
          <template v-slot:tagSlot="col">
            <el-link type="primary" @click="editParticulars(col.scope.row)">{{ col.scope.row.fbillNo }}</el-link>
          </template>
        </jc-table>
      </div>
    </div>
    <div class="shouye daohang">快捷导航</div>
    <hr class="hr1">
    <ul class="skipUrl">
      <li v-for="item in saleData" :key="item.name" @click="newlyOrder(item.path)">{{ item.name }}</li>
    </ul>
    <hr class="hr1">
    <div class="fotter">
      <bar class="bar" />
      <lines class="line" />
    </div>
  </div>
</template>

<script>
import { queryReportPooHeader, queryLatePoorderList } from '@/api/homePageNew/salesman'
import { toMxAmina } from '@/components/ToMxamineState'
import { mapGetters } from 'vuex'
import bar from '@/views/homePageNew/purchasing/component/bar'
import lines from '@/views/homePageNew/purchasing/component/line'
export default {
  name: 'Salesman',
  components: {
    bar,
    lines
  },
  data() {
    return {
      headerInfo: {
        patTotal: 0,
        requisiTotal: 0,
        pooTotal: 0,
        poowrTotal: 0,
        stockTotal: 0
      },
      saleData: [
        { name: '供应商列表', path: '/supplierList' },
        { name: '采购调价表', path: '/modifyPriceList' },
        { name: '采购价目表', path: '/purchasePriceList' },
        { name: this.$t('menu.purOrderAsi'), path: '/purchaseOrderList' },
        { name: this.$t('menu.storageTong'), path: '/storageList' },
        { name: this.$t('menu.returnMater'), path: '/returnMaterList' },
        { name: '采购申请单', path: '/applyList' }
      ],
      detailsData: [],
      detailsHeader: [
        { label: this.$t('market.billNo'), type: 'tag', prop: 'fbillNo', width: '120' },
        { label: this.$t('market.paezText1'), prop: 'fpaeztext' },
        { label: this.$t('market.suppliername'), prop: 'fsupplier', align: 'left', width: '200' },
        { label: this.$t('market.fmaterial'), prop: 'fnumber', width: '110' },
        { label: this.$t('shop.fname2'), prop: 'fname', minWidth: '100' },
        { label: this.$t('market.fmodel'), prop: 'fmodel' },
        { label: this.$t('shop.fspecificaTion'), prop: 'fspecificaTion' },
        { label: this.$t('market.ftaxPrice'), prop: 'ftaxprice', width: '80' },
        { label: this.$t('market.fqty'), prop: 'fqty', width: '80' },
        { label: '已入库数', prop: 'frealqty', width: '80' },
        { label: '最后入库时间', prop: 'fstockdate', width: '100' },
        { label: this.$t('market.consignDate'), prop: 'fdeliverydate', width: '100' }
      ]
      // userName: '陈镜伊'
    }
  },
  computed: {
    ...mapGetters(['userName'])
  },
  created() {
    this.detailsList() // 销售订单列表
    this.headerDetail() // 头部信息
  },
  methods: {
    // 头部信息
    async headerDetail() {
      await queryReportPooHeader({}).then(res => {
        this.headerInfo = res.data
      })
    },
    // 即将迟交订单明细列表
    async detailsList() {
      const DATA = {
        pageNum: 1,
        pageSize: 200,
        search: this.searCollData
      }
      const { data: RES } = await queryLatePoorderList(DATA)
      this.detailsData = RES.array.map(item => {
        return toMxAmina(item)
      })
    },
    // 价目详情
    editParticulars(ev) {
      const id = ev.fid
      this.$router.push({ path: `/editPurchase/${id}` })
    },
    // 跳转
    newlyOrder(path) {
      this.$router.push({ path: path })
    },
    // 待审核销售单
    pushView(ev) {
      this.$router.push({ path: '/modifyPriceList', query: {
        fsaler: this.userName,
        fdocumentStatus: ev
      }
      })
    },
    // 采购订单
    pushView1(ev) {
      this.$router.push({ path: '/purchaseOrderList', query: {
        fsaler: this.userName
      }
      })
    },
    // 采购入库单
    pushView2(ev) {
      this.$router.push({ path: '/storageList', query: {
        fsaler: this.userName
      }
      })
    }
  }
}
</script>

<style scoped lang="scss">
.purchasing {
  padding: 10px;
  background: #FFFFFF;
  .shouye {
    padding-bottom: 5px;
    font-size: 18px;
    letter-spacing: 2px;
    font-weight: 550;
  }
  .hr1 {
    margin-bottom: 10px;
    border: 0;
    height: 1px;
    //background-image: linear-gradient(to right, #aa1d1d, #b3931d, #4aad1f, #1fa588, #1C3BAC, #971DA5, #aa1d1d);
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0.1), rgba(0, 121, 248, 0.5), rgba(0, 0, 0, 0.1));
  }
  .daohang {
    font-size: 16px;
    font-weight: 550;
    color: #333;
  }
  .header {
    display: flex;
    justify-content: space-around;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    li {
      list-style: none;
      width: 12%;
      max-width: 300px;
      min-width: 200px;
      height: 70px;
      padding: 10px;
      background-color: rgb(64,158,255,0.1);
      border-radius: 2px;
      display: flex;
      flex-direction: column;
      align-items: center;
      position: relative;
      .firstHead {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        text-align: center;
        font-size: 16px;
        color: #FFF;
        background: #409EFF;
        padding: 5px 0;
        font-weight: 600;
        letter-spacing: 2px;
      }
      .lastHead {
        font-size: 28px;
        color: #666;
        line-height: 75px;
        font-weight: 600;
      }
    }
  }
  .context {
    //display: flex;
    //justify-content: space-around;
    //align-items: center;
    min-height: 400px;
    margin: 15px 0;

    .rightListTop {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 5px 0;
    }
  }
  .fotter {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    .line, .bar {
      position: relative;
      width: 50%;
    }
  }
  .skipUrl {
    margin: 20px 0;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0;
    li {
      cursor: pointer;
      width: 100px;
      height: 100px;
      line-height: 100px;
      text-align: center;
      border-radius: 50%;
      color: #FFFFFF;
      transition: all 0.3s;
      background-image: linear-gradient(to right bottom, #ABDCFF, #0396FF);
    }
    li:hover {
      border-radius: 20px;
    }
  }
}
</style>
